<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>选择成本中心</title>
    <link rel="stylesheet" href="../../../css/aui.css" />
    <link rel="stylesheet" href="../../../css/iconfont/iconfont.css" />
    <link rel="stylesheet" href="../../../css/index/train/select_cost_center.css" />
</head>

<body style="cursor: pointer">
    <!--头部start-->
    <header class="aui-bar aui-bar-nav" style="background: #3CB0D6;" id="header">
        <a class="aui-pull-left aui-btn" onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title">选择成本中心</div>
    </header>
    <!--头部end-->
    <div class="cost_center_name">
        部门成本中心
    </div>
    <ul class="cost_list">
        <!--<li>-->
        <!--<div class="cost_detail_left">-->
        <!--公司-->
        <!--</div>-->
        <!--<div class="detail_right">-->
        <!--<i class="aui-iconfont aui-icon-right"></i>-->
        <!--</div>-->
        <!--</li>-->
    </ul>
    <!--<div class="cost_center_name">-->
    <!--自定义成本中心-->
    <!--</div>-->
    <!--<ul class="cost_list">-->
    <!--<li>-->
    <!--<div class="cost_detail_left">-->
    <!--测试-->
    <!--</div>-->
    <!--<div class="detail_right">-->
    <!--<i class="aui-iconfont aui-icon-right"></i>-->
    <!--</div>-->
    <!--</li>-->
    <!--</ul>-->
</body>
<script type="text/javascript" src="../../../script/extend/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../../../script/aui/api.js"></script>
<script type="text/javascript" src="../../../script/config.js"></script>
<script type="text/javascript" src="../../../script/common.js"></script>
<script>
    apiready = function() {
        api.parseTapmode();

        //设置高度
        var header = $api.byId('header');
        $api.fixStatusBar(header);

        var user_id = api.pageParam.user_id;
        ajax({
            url: Config.common.getUsersCostList,
            data: {
                userIds: user_id
            }
        }, function(data) {
            if (data.code == 1) {
                var res = data.data[user_id].costList;
                var html = '';
                $.each(res, function(key, val) {
                    html += '<li onclick="selected_cost(' + val.cost_center_id + ')"><div id="' + val.cost_center_id + '" class="cost_detail_left">' + val.cost_name + '</div><div class="detail_right"></div></li>';
                })
                $('.cost_list').append(html);
            }
        })
    };

    //选中成本中心列表
    function selected_cost(cost_id) {
        var cost_name = $('#' + cost_id).text();
        api.sendEvent({
            name: 'selectCostEvt',
            extra: {
                cost_id: cost_id,
                cost_name: cost_name
            }
        });
        setTimeout(function() {
            api.closeWin();
        }, 500);
    }
</script>

</html>
